package com.catmiw.wyz;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args ) throws IOException
    {
        String path="D:/����׿�Ľ���/��ѧ/�¹��Ĺ�ֹ��ע/";
    	File f=new File(path);
        
        String[] files=f.list();
        for (String s:files){
        	String name=null;
        	if (s.length()==7){
        		String t1=s.substring(0,3);
        		int i=Integer.parseInt(t1);
        		
        		t1=""+i;
        		
        		String fn=path+s;
        		File ff=new File(fn);
        		BufferedReader fr=new BufferedReader(new FileReader(ff));
        		String temp=null;
        		while((temp=fr.readLine())!=null){
        			if (temp.startsWith(t1)){
        				name=s.substring(0,3)+temp.substring(t1.length())+".txt";
        				break;
        			}
        		}
        		fr.close();
        		ff.renameTo(new File(path+name));
        	}
        }
        
    	System.out.println( "Hello World!" );
    }
}
